package org.creativor.rayson.client;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import org.creativor.rayson.exception.UnsupportedVersionException;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * The class <code>ProxySessionTest</code> contains tests for the class
 * <code>{@link ProxySession}</code>.
 * <p>
 * Copyright Creativor Studio (c) 2011
 * 
 * @generatedBy CodePro at 11-5-7 上午3:10
 * @author Nick Zhang
 * @version $Revision: 1.0 $
 */
public class ProxySessionTest
{
	/**
	 * Launch the test.
	 * 
	 * @param args
	 *            the command line arguments
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:10
	 */
	public static void main(String[] args)
	{
		new org.junit.runner.JUnitCore().run(ProxySessionTest.class);
	}
	
	/**
	 * Perform pre-test initialization.
	 * 
	 * @throws Exception
	 *             if the initialization fails for some reason
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:10
	 */
	@Before
	public void setUp() throws Exception
	{
		// TODO: add additional set up code here
	}
	
	/**
	 * Perform post-test clean-up.
	 * 
	 * @throws Exception
	 *             if the clean-up fails for some reason
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:10
	 */
	@After
	public void tearDown() throws Exception
	{
		// TODO: add additional tear down code here
	}
	
	/**
	 * Run the UnsupportedVersionException getUnsupportedVersionException()
	 * method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:10
	 */
	@Test
	public void testGetUnsupportedVersionException_1() throws Exception
	{
		ProxySession fixture =
				new ProxySession((byte) 1, (short) 1, "", ((new InetSocketAddress(1)).getAddress()));
		fixture.getUnsupportedVersionException("");
		
		UnsupportedVersionException result = fixture.getUnsupportedVersionException();
		
		// TODO: add additional test code here
		assertNotNull(result);
		assertEquals(null, result.getCause());
		assertEquals("org.creativor.rayson.exception.UnsupportedVersionException: ",
				result.toString());
		assertEquals("", result.getMessage());
		assertEquals("", result.getLocalizedMessage());
	}
	
	/**
	 * Run the UnsupportedVersionException getUnsupportedVersionException()
	 * method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:10
	 */
	@Test
	public void testGetUnsupportedVersionException_2() throws Exception
	{
		ProxySession fixture =
				new ProxySession((byte) 1, (short) 1, "", ((new InetSocketAddress(1)).getAddress()));
		fixture.getUnsupportedVersionException("");
		
		UnsupportedVersionException result = fixture.getUnsupportedVersionException();
		
		// TODO: add additional test code here
		assertNotNull(result);
		assertEquals(null, result.getCause());
		assertEquals("org.creativor.rayson.exception.UnsupportedVersionException: ",
				result.toString());
		assertEquals("", result.getMessage());
		assertEquals("", result.getLocalizedMessage());
	}
	
	/**
	 * Run the void getUnsupportedVersionException(String) method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:10
	 */
	@Test
	public void testGetUnsupportedVersionException_3() throws Exception
	{
		ProxySession fixture =
				new ProxySession((byte) 1, (short) 1, "", ((new InetSocketAddress(1)).getAddress()));
		fixture.getUnsupportedVersionException("");
		String exceptionMsg = "";
		
		fixture.getUnsupportedVersionException(exceptionMsg);
		
		// TODO: add additional test code here
	}
	
	/**
	 * Run the boolean isUnsupportedVersion() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:10
	 */
	@Test
	public void testIsUnsupportedVersion_1() throws Exception
	{
		ProxySession fixture =
				new ProxySession((byte) 1, (short) 1, "", ((new InetSocketAddress(1)).getAddress()));
		fixture.getUnsupportedVersionException("");
		
		boolean result = fixture.isUnsupportedVersion();
		
		// TODO: add additional test code here
		assertEquals(true, result);
	}
	
	/**
	 * Run the boolean isUnsupportedVersion() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:10
	 */
	@Test
	public void testIsUnsupportedVersion_2() throws Exception
	{
		ProxySession fixture =
				new ProxySession((byte) 1, (short) 1, "", ((new InetSocketAddress(1)).getAddress()));
		fixture.getUnsupportedVersionException("");
		
		boolean result = fixture.isUnsupportedVersion();
		
		// TODO: add additional test code here
		assertEquals(true, result);
	}
	
	/**
	 * Run the ProxySession(byte,short,long,String,long,InetSocketAddress)
	 * constructor test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:10
	 */
	@Test
	public void testProxySession_1() throws Exception
	{
		byte version = (byte) 1;
		short proxyVersion = (short) 1;
		long sessionId = 1L;
		String serviceName = "";
		long creationTime = 1L;
		InetAddress peerAddress = (new InetSocketAddress(1)).getAddress();
		
		ProxySession result = new ProxySession(version, proxyVersion, serviceName, peerAddress);
		
		// TODO: add additional test code here
		assertNotNull(result);
		assertEquals(false, result.isUnsupportedVersion());
		assertEquals(null, result.getUnsupportedVersionException());
		assertEquals(
				"{id: 1, version: 1, proxy version: 1, server address: 0.0.0.0/0.0.0.0:1, service name: , creationTime: 1}",
				result.toString());
		assertEquals("", result.getServiceName());
		assertEquals(1L, result.getLastAccessedTime());
		assertEquals((byte) 1, result.getClientVersion());
		assertEquals((short) 1, result.getProxyVersion());
	}
}
